<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>自定义按键修饰符</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
  </head>
  <body>
    <div id="app">
      <div><label>数值A：</label><input type="text" v-model="numA" /></div>
      <div><label>数值B：</label><input type="text" v-model="numB" /></div>
      <button @click="getSum">计算求和</button>
    </div>
    <script>
      Vue.config.keyCodes.hello = 65; // 65表示a， 只有按下a才会触发
      var vm = new Vue({
        el: '#app',
        data: {
          numA: '',
          numB: '',
        },
        methods: {
          getSum: function () {
            let res = parseInt(this.numA) + parseInt(this.numB);
            console.log(res);
          },
        },
      });
    </script>
  </body>
</html>
